<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://www.yaodian100.com/jsp/yaodian100" prefix="yaodian100" %>
<%@ include file="/taglibs.jsp"%>
<!-- 数字验证 -->

<script type="text/javascript" charset="UTF-8" src="/js/jquery.alphanumeric.js"></script>		
<!-- 月历 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick-zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="/css/smoothness.datepick.css"/>
<!-- 時間 -->	
<script type="text/javascript" src="/js/jquery.timePicker.js"></script>
<link rel="stylesheet" type="text/css" href="/css/timePicker.css"/>	
<s:actionerror cssClass="errmsg"/>
<s:actionmessage cssClass="errmsg"/>
<br/>
  <h1>编辑资料 - 批次修改上架中商品促销小标</h1>
  <div class="batchstep">
    <div class="batchstep-2">
      <span class="step1">Step 1：查寻商品/选取商品</span>
      <span class="onstep2">Step 2：编辑资料</span>
      <span class="step3">Step 3：核对资料/完成编辑</span>
    </div>
  </div>
<script>
$().ready( function() {
	$("#newsubmit").click(function() {
		//alert($("input[name=pid]").length);
		var error = 0;
		if($("#promoteNameParam").val().length>20){
			$("#wordCountError").show();
			error++;
		}else{
			$("#wordCountError").hide();
		}
		if(error>0){
			return;
		}
		//商品促銷小標
		$('input[id^="promoteName_"]').attr("value", $("#promoteNameParam").val());
		if(error==0){
			$("#dataoldornew").val("new");
			$("#oldsubmit").attr("disabled",true); 
			$("#nextsubmit").hide();
			$("#errtable").hide();			
			$("#confirmForm").submit();
		}
			
	});

	$("#oldsubmit").click(function() {
		$("#dataoldornew").val("old");
		$("#newsubmit").attr("disabled",true); 
		$("#promoteNameParam").attr("disabled",true); 
		$("#nextsubmit").hide();
		$("#errtable").hide();	
		$("#confirmForm").submit();
		
	});
	$("#mainSubmit").click(function(){
		if ( "" == $("#MultiFile8_F1").val()){
			alert("尚未选择上传档案，请重新选择！");
			return false;
		}
	});
});

function sumbitF(){
	var error = 0;
	$("input[name=pid]").each(function(index){
			var key = $(this).val();
			if($.trim($("#promoteName_"+key).val()).length>20){		
				$("#wordCountError_"+key).show();
				error++;
			}else{
				$("#wordCountError_"+key).hide();
			}						
	});
	if(error>0){
		return;
	}else{	
		$("#confirmForm").submit();
	}
}

</script>
  <!-- div class="data-form"> -->
   <img src="/images/ecadmin/bianjiziliaoliucheng.jpg"></img>
   <div class="tipmsg" style="width:53%"><ul><li>系统会将你所选定的商品自动生成Excel报表，请在信息编辑完成后，下载报表。<br/>此阶段具有时效性，请在<Strong>25分钟</Strong>内完成编辑，并上传相关Excel报表</li></ul></div>
   <h2>下载报表</h2>	
	<s:form action="downloadFile.do" method="post" id="confirmForm">
	<s:hidden name="paramBatchEventId"/>
		<table class="tb-edit" style="width:53%">
          <tbody><tr>
          	<th>商品促銷小標</th><td>            
            <input type="text" name="promoteNameParam" id="promoteNameParam" size="30" maxlength="20" value="">
            <span class="txt-gy">上限20个汉字</span>
            <div class="errmsg" id="wordCountError" style="display:none"><ul><li><span>商品促銷小標超过上限20个汉字</span></li></ul></div>
            </td>
          </tr>          
          <tr>
            <th></th>
            <td><input type="button" id="newsubmit" value="全部套用，下载Excel报表 ">
            <input type="hidden" id="dataoldornew" name="dataoldornew">
            <c:if test="${!empty event.modifyDate}"><input type="button" id="oldsubmit" value="下载之前上传的报表 "></c:if>
            </td>
          </tr>         
        </tbody></table>
        <br />
      <br /> 
	  	<div style="display:none">
		<s:iterator value="detailMap" var="map" status="rows_index">
		<input type="hidden" name="pid" value="${map.key}">      
           <s:textfield size="10"  name="detailMap['%{#map.key}'].dataNewMap['promoteName']" id="promoteName_%{#map.key}" value="%{#map.value.dataNewMap['promoteName']}" maxlength="20"/>
		</s:iterator>
  		</div>  
      	</s:form>     
      <br />
      	 <h2>上传报表</h2>
      	 <div class="tipmsg"  style="width:53%"><ul><li>请将核对编辑后的报表上传。</li></ul></div>
		<s:form action="uploadFile.do" method="post" enctype ="multipart/form-data">
	    	<table style="width:53%;clear:none;" border="0" align="left" class="tb-data">		
		        <tr>
		          	<td><input id="MultiFile8_F1" class="multi accept-xls" maxlength="1" type="file" name="upload"  accept="xls"/>
		          	<s:submit id="mainSubmit" value="上传Excel报表" /><br><br>
		         	<c:if test="${!empty step2Upload}">
			         	<div style="width:100%;font-size: 15px;" id="errtable">
			         	上传成功${uploadSuccess}笔<br />
			         	上传失败${uploadErr}笔<br />
				         	<c:if test="${!empty errId}">
				         	上传失败的商品编号（最多显示20笔）:
					         	<c:forEach items="${errId}" var="errId" varStatus="rows_index">
					         	${errId} / 
					         	</c:forEach>	         		
				         	</c:if>
			         	</div>
		         	</c:if>
		         	</td>
		       </tr>
	    	 </table>
	   </s:form>
       <s:form action="confirm.do">
        <table width="560"  border="0"><tr height="40"><td>
     	 <br /><c:if test="${empty event.modifyDate}"><a href="changePage.do" class="pstep">﹤回上一步</a></c:if> 
      	<c:if test="${uploadSuccess>0 and uploadErr<=0}">
      		<input type="submit" id="nextsubmit" value="上传完成！下一步﹥" class="nstep" ><br />
		</c:if>
		</td></tr></table>
     </s:form>

    <!-- </div>  -->